package com.example.agenda;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ListView;

import com.example.adapter.ListaAdapter;
import com.example.agenda.presenter.ContactsPresenter;
import com.example.agenda.view.ContactsView;
import com.example.vo.ContactDetails;

public class MainActivity extends Activity implements ContactsView {
	private ContactsPresenter contactsPresenter;
	ListaAdapter listAdapter;

	public MainActivity() {
		contactsPresenter = new ContactsPresenter(this);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_main);

		contactsPresenter.go();
	}

	@Override
	protected void onResume() {
		super.onStart();

		contactsPresenter.go();
	}

	public Button getButtontAdd() {
		return (Button) findViewById(R.id.btAdd);
	}

	public Button getButtontDel() {
		return (Button) findViewById(R.id.btDel);
	}

	public ListView getListView() {
		return (ListView) findViewById(R.id.lstContatos);
	}

	public Context asWidget() {
		return this;
	}

	public void setData(List<ContactDetails> contactDetails) {
		listAdapter = new ListaAdapter(this, contactDetails);

		getListView().setAdapter(listAdapter);
	}

	public List<String> getSelectedRows() {
		
		return listAdapter.getSelectItens();
	}
}